<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表单</title>
    <link rel="stylesheet" href="__STATIC__/frame/layui/css/layui.css">
    <link rel="stylesheet" href="__STATIC__/frame/static/css/style.css">
    <link rel="stylesheet" href="__STATIC__/css/maowenke.css">
    <link rel="icon" href="__STATIC__/frame/static/image/code.png">
</head>
<body class="body">
<form id="form" method="post">
    <input type="text" name="id" value="{$data['id']}" style="display: none">
    <div class="layui-form-item layui-form-text" style="margin-top: 15px">
        <label class="layui-form-label">题干</label>
        <div class="layui-input-block">
            <textarea name="stem" placeholder="请输入内容" class="layui-textarea">{$data['stem']}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text" style="margin-top: 15px">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-block">
            <div class="file">
                <input type="file" name="picture">点击预览
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-form-text" style="margin-top: 15px">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <div class="show">
        {if $data['picture']}
                <img src="{:GetImg($data['picture'])}" width="100">
                {/if}
            </div>
        </div>
    </div>
<div class="layui-form-item layui-form-text" style="margin-top: 15px">
    <label class="layui-form-label">答案</label>
    <div class="layui-input-block">
        <textarea name="answer" placeholder="请输入答案，答案以中文'；。',英文';'分开" class="layui-textarea">{foreach $data['answer'] as $value}{$value};{/foreach}</textarea>
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">正确答案</label>
    <div class="layui-input-block">
        <input type="text" name="right_key" value="{$data['right_key']}"  lay-verify="required" placeholder="请输入正确答案A,B,C,D...." autocomplete="off" class="layui-input">
    </div>
</div>
<div class="layui-form-item layui-form-text">
    <label class="layui-form-label">做题思路</label>
    <div class="layui-input-block">
        <textarea name="thinking" placeholder="请输入做题思路" class="layui-textarea">{$data['thinking']}</textarea>
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">获取的金币</label>
    <div class="layui-input-block">
        <input type="number" name="coin" value="{$data['coin']}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
    </div>
</div>
    <div class="layui-form-item">
        <label class="layui-form-label">获取的经验</label>
        <div class="layui-input-block">
            <input type="number" name="experience" value="{$data['experience']}"  lay-verify="required" placeholder="请输入经验值" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">题目难度</label>
        <div class="layui-input-block">
            <input type="number" name="difficulty" value="{$data['difficulty']}"  lay-verify="required" placeholder="请输入经验值" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">题目模式</label>
        <div class="layui-input-block">
            <select class="layui-select" name="type">
                {foreach $situation as $value}
                {if $value['id']==$data['type']}
                <option value="{$value['id']}" selected>{$value['situation_name']}</option>
                {else}
                <option value="{$value['id']}">{$value['situation_name']}</option>
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
</form>
<div class="layui-row" style="text-align: center;margin-top: 30px">
    <button class="layui-btn" id="tijiao">提交</button>
</div>
<script src="__STATIC__/frame/layui/layui.all.js" charset="utf-8"></script>
<script src="__STATIC__/js/jquery.3.3.1.min.js" charset="utf-8"></script>
<script src="__STATIC__/js/maowenke.js" charset="utf-8"></script>
<script>
$("#tijiao").click(function () {
    ajaxs($("#form"),"{:url('update/question_bank')}",function (data) {
        console.log(data);
        if(data.code==200){
            layer.msg(data.msg);
            setTimeout(function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            },1500);
        }else{
            layer.msg(data.msg);
        }
    })
});
$("[name=picture]").change(function () {
    showImages($(this),$(".show"),'100');
});
$("[name=classid]").change(function () {
    get_branch();
})
function get_branch() {
        var $id = $("[name=classid]").val();
        $.post("{:url('Api/get_Branch')}",{id:$id},function (data) {
            if(data.code==200){
                $("[name=branchid]").empty();
                var $str = '';
                $.each(data.data,function (i,v) {
                    $str +='<option value="'+v.id+'">'+v.branch_name+'</option>';
                });
                $("[name=branchid]").append($str);
            }else{
                layer.msg(data.msg);
            }
        })
}
</script>
</body>
</html>